package com.lc.service.impl;

import com.lc.config.annos.Autowired;
import com.lc.config.annos.Service;
import com.lc.config.annos.Transactional;
import com.lc.dao.AccountMapper;
import com.lc.service.TransferService;

import java.sql.SQLException;

/**
 * @author liuc
 * @date 2021/4/18
 * @description
 **/
@Service("transferService")
public class TransferServiceImpl implements TransferService {

    @Autowired
    private AccountMapper accountMapper;

    public AccountMapper getAccountMapper() {
        return accountMapper;
    }

    public void setAccountMapper(AccountMapper accountMapper) {
        this.accountMapper = accountMapper;
    }

    @Override
    @Transactional
    public void transfer(int from , int to, int money) throws SQLException {
        accountMapper.transfer(from,money);
        int i = 1 / 0;
        accountMapper.transfer(to,-money);
    }
}
